package com.zrm.zfcrpa.controller;

import com.alibaba.fastjson.JSONObject;
import com.zrm.zfcrpa.utils.MyJwtUtils;
import com.zrm.zfcrpa.vo.ResultResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;


@RestController
public class HealthController {
	private Logger logger = LoggerFactory.getLogger(HealthController.class);

	@Autowired
	private RedisTemplate redisTemplate;


	@GetMapping("/test")
	public ResultResponse<String> healthCheck() {
		return ResultResponse.success("test");
	}

	@GetMapping("/testadmin")
	@PreAuthorize("hasAnyAuthority('人行总行普通用户','超级管理员')")
	public ResultResponse<String>  admin(){
		return ResultResponse.success("admin");
	}

	@GetMapping("/testuser")
	@PreAuthorize("hasAnyAuthority('企业用户')")
	public ResultResponse<String>  user(){
		return ResultResponse.success("user");
	}

	@GetMapping("/index")
	@PreAuthorize("hasAnyAuthority('人行总行普通用户','超级管理员')")
	public ResultResponse<JSONObject>  index(){
		JSONObject object1 = MyJwtUtils.userObject();
		return ResultResponse.success(object1);
	}


}
